package com.edu.zut.hb.software.server.controller;


import com.edu.zut.hb.software.server.service.IMqmsgService;
import com.edu.zut.hb.software.server.service.MqProducer;
import com.edu.zut.hb.software.server.pojo.Mqmsg;
import com.edu.zut.hb.software.server.pojo.RespBean;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author ifax
 * @since 2021-08-20
 */
@RestController
@RequestMapping("/mq")
public class MqmsgController {

    @Autowired
    IMqmsgService mqmsgService;
    @Autowired
    MqProducer mqProducer;

    @ApiOperation(value = "获取所有消息")
    @GetMapping("/get/all")
    public List<Mqmsg> getAllAdmins() {
        return mqmsgService.list();
    }

    @ApiOperation(value = "发送文本信息")
    @PostMapping("/send")
    public RespBean sendMessage(@RequestBody Mqmsg msg) {
        mqProducer.sendQueue(msg);
        return RespBean.success("发送成功!");
    }

}
